{% extends 'template.html' %}
{% load staticfiles %}

{% block username %}
    {{ request.user.username }}
{% endblock %}

{% block content %}
    <div id="page-wrapper">
        <div class="row">
            <div class="col-lg-12">
                <h2 class="page-header">特殊人员配置</h2>
            </div>
        </div>
        <div class="alert alert-info">
            <p><i class="fa fa-check"></i> 维护工单流程中，特殊的参数配置</p>
        </div>
        <div class="row">
            <div class="col-lg-12">
                <div class="panel panel-default">
                    <div class="panel-heading">
                        <div class="btn-group">
                            <a>
                                <button type="button" class="btn btn-success" onclick="bt_add()">新增
                                </button>
                            </a>
                            <a>
                                <button id='bt-del' data-text="确定删除审批人? 0个" type="button"
                                        class="btn btn-danger">删除
                                </button>
                            </a>
                        </div>
                    </div>
                    <div class="panel-body">
                        {% if special_config %}
                            <table id="mytable" width="100%" cellspacing="0"
                                   class="table table-striped table-hover">
                                <thead>
                                <tr>
                                    <th class="center sorting_disabled">
                                        <label class="pos-rel">
                                            <input id='chb-all' type="checkbox"/>
                                        </label>
                                    </th>
                                    <th style="display: none;">id</th>
                                    <th>参数用途</th>
                                    <th>关联人员</th>
                                    <th>参数名称</th>
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                {% for config in special_config %}
                                    <tr>
                                        <td class=" dt-body-center"><input type="checkbox"></td>
                                        <td style="display: none;" id="{{ config.id }}"
                                            value="{{ config.id }}"
                                            name="{{ config.id }}">{{ config.id }}</td>
                                        <td>{{ config.remark }}</td>
                                        <td>
                                            {% for user in config.user.all %}
                                                <span>{{ user.username }}</span>,
                                            {% endfor %}
                                        </td>
                                        <td>{{ config.param }}</td>
                                        <td>
                                            <button class="btn btn-sm btn-primary" onclick="edit({{ config.id }})">
                                                修改
                                            </button>
                                        </td>
                                    </tr>
                                {% endfor %}
                                </tbody>
                            </table>
                        {% else %}
                            <p>还没有特殊人员配置信息，请先添加！</p>
                        {% endif %}
                    </div>
                </div>
            </div>

            <!-- Add or Edit Modal-->
            <div class="modal fade" id="Modal" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                <div class="modal-dialog">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                            <h4 class="modal-title" id="myModalLabel"></h4>
                        </div>
                        <form class="form-horizontal">
                            <div class="modal-body">
                                <input style="display: none;" id="id_config">
                                <div class="alert alert-danger alert-dismissable" id='modal-notify'>
                                    <button type="button" class="close" data-dismiss="alert">&times;</button>
                                    <label id='lb-msg'></label>
                                </div>
                                <div class="form-group">
                                    <label class="control-label col-md-3">参数名称</label>
                                    <div class="col-md-8">
                                        <input class="form-control" type="text" id="id_param" placeholder="请输入参数名称">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="control-label col-md-3">备注</label>
                                    <div class="col-md-8">
                                        <input class="form-control" type="text" id="id_remark" placeholder="请输入参数备注">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="control-label col-md-3">关联人员</label>
                                    <div class="col-md-8">
                                        <select id="id_special_user" class="form-control" multiple="multiple"
                                                style="width: 100%">
                                        </select>
                                    </div>
                                </div>
                            </div>
                            <div class="modal-footer">
                                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                                <button type="button" class="btn btn-primary" name='action'
                                        id="bt-save">保存
                                </button>
                            </div>
                        </form>
                    </div><!-- /.modal-content -->
                </div><!-- /.modal-dialog -->
            </div>

        </div>
    </div>
{% endblock %}
{% block bodyjs %}
    <script src="/static/js/select2.min.js"></script>
    <script src="/static/js/jquery.dataTables.min.js"></script>
    <script src="/static/js/dataTables.colVis.js"></script>
    <script src="/static/js/special_user_config.js?v=20190628001"></script>
{% endblock %}
{% block css %}
    <link href="/static/css/jquery.dataTables.css" rel="stylesheet" type="text/css">
    <link href="/static/css/dataTables.colVis.css" rel="stylesheet" type="text/css">
{% endblock %}
